package com.sensePlusVR.utils;

import com.sensePlusVR.bean.CpuInfo;

import java.util.HashMap;
import java.util.Map;

public class CpuMediaInfo {
	private static final String TAG = "CpuMediaInfo";
	private static CpuInfo mCpuInfo;
	private static Map<String, DecoderRes> mRes = new HashMap<String, DecoderRes>();
	static {
		mRes.put("720P", DecoderRes.RES720P);
		mRes.put("1080P", DecoderRes.RES1080P);
		mRes.put("2k", DecoderRes.RES2K);
		mRes.put("4k", DecoderRes.RES4K);
		mRes.put("2560x1280", DecoderRes.RES2560x1280);
	}
    public enum DecoderRes {
        UNKNOWN, RES4K, RES2K, RES1080P, RES720P, RES480P, RES2560x1280
    }
    private static class HWDecoderLimiteBySOC {
        public final String key;
        public final String value;
		public DecoderRes dRes;

        public HWDecoderLimiteBySOC(String key, String value, DecoderRes dres) {
            this.key = key;
            this.value = value;
            this.dRes = dres;
        }
    }
	private static final HWDecoderLimiteBySOC[] sHWDecoderLimiteBySOCList = new HWDecoderLimiteBySOC[]{
			new HWDecoderLimiteBySOC("ro.hardware", "mt6735", DecoderRes.RES1080P),
			new HWDecoderLimiteBySOC("ro.boot.hardware", "mt6735", DecoderRes.RES1080P),
			new HWDecoderLimiteBySOC("ro.boot.hardware", "samsungexynos44", DecoderRes.RES1080P),
			new HWDecoderLimiteBySOC("ro.boot.hardware", "samsungexynos42", DecoderRes.RES1080P),
			new HWDecoderLimiteBySOC("ro.boot.hardware", "samsungexynos34", DecoderRes.RES1080P),
			new HWDecoderLimiteBySOC("ro.boot.hardware", "samsungexynos31", DecoderRes.RES1080P),
		};
	
//	public static DecoderRes getDecoderLimite() {
//    	if (mCpuInfo == null){
//    		mCpuInfo = VRApplication.getInstance().getCPUInfo();
//    	}
//    	if (mCpuInfo != null && !mCpuInfo.getCpucode().equals("unknow")){
//    		String sres[] = mCpuInfo.getHwdecoder().split("@");
//    		Log.e(TAG, "hwdecoder resolution="+sres[0]);
//    		String sreslow = sres[0].toLowerCase();
//    		String sresup = sres[0].toUpperCase();
//    		DecoderRes rt = mRes.get(sreslow);
//    		if (rt == null){
//    			rt = mRes.get(sresup);
//    		}
//    		return rt;
//    	}
//		for (HWDecoderLimiteBySOC decBySOC : sHWDecoderLimiteBySOCList) {
//			Log.e(TAG, "prop="+decBySOC.key+", cpu="+decBySOC.value);
//            final String prop = SystemProperty.getSystemPropertyCached(decBySOC.key);
//            if (prop != null) {
//				//Log.e(TAG, "prop="+decBySOC.key+", cpu="+decBySOC.value + ", realcpu="+prop);
//                if (prop.contains(decBySOC.value))
//                    return decBySOC.dRes;
//            }
//        }
//        return DecoderRes.UNKNOWN;
//    }
}
